<!--
 * @Descripttion: 
 * @version: 
 * @Author: weihua.yao
 * @Date: 2020-02-27 16:05:50
 * @LastEditTime: 2020-02-27 16:11:21
 -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var i
    for (let i = 0; i < 10; i++) {
      (
        function (i) {
          var a = document.createElement('a')
          a.innerHTML = i + '<br>'
          a.addEventListener('click', function (e) {
            e.preventDefault()
            alert(i)
          })
          document.body.appendChild(a)
        }
       )(i)
    }
  </script>
</body>

</html>